﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MSBDATAModel;

public partial class Admin_XemGiaoDichKH : System.Web.UI.Page
{
    MSBDATAEntities entities = new MSBDATAEntities();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
        }
    }
    protected void EntityDataSource1_Updated(object sender, EntityDataSourceChangedEventArgs e)
    {
        GIAO_DICH_KHACH_HANG gd =(GIAO_DICH_KHACH_HANG)e.Entity;
        if (gd.DuocDuyet == true)
        {
            try
            {
                THE_THANH_TOAN the = entities.THE_THANH_TOAN.First(t => t.SoThe == gd.MaTKGiaoDich);
                the.TAI_KHOAN_NGAN_HANG.SoTien += gd.SoTien;

                if (entities.SaveChanges() > 0)
                {
                    this.LabelStatus.Text = "Đã nạp tiền cho tài khoản " + the.SoThe + " số tiền " + gd.SoTien;
                }
                
            }
            catch (Exception) {
                this.LabelStatus.Text = "Xảy ra lỗi";
            }
        }
    }
}